// pages/quanyi/quanyi.js
import request from '../../utils/http.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    equitylist:[],
    roleTexts: {
      1: { text: '财参堂产品', image: '/image/cstcp.png' },
      2: { text: '定制个人歌曲', image: '/image/dzgrgq.png' },
      3: { text: '健康课程学习', image: '/image/jkkcxx.png' },
      4: { text: '健康圈私享会', image: '/image/jkqsxh.png' },
      5: { text: '公司推介会', image: '/image/gstjh.png' },
      6: { text: '人参宴', image: '/image/rsy.png' },
      7: { text: '专家问诊', image: '/image/zjwz.png' },
      8: { text: '免费机器人检测', image: '/image/jqrmfjc.png' },
      9: { text: '公司分红', image: '/image/gsfh.png' },
      10: { text: '健康圈资源', image: '/image/jkqzy.png' },
    },
    roleImages: {
      1: '/image/cstcp.png',
      2: '/image/dzgrgq.png',
      3: '/image/jkkcxx.png',
      4: '/image/jkqsxh.png',
      5: '/image/gstjh.png',
      6: '/image/rsy.png',
      7: '/image/zjwz.png',
      8: '/image/jqrmfjc.png',
      9: '/image/gsfh.png',
      10: '/image/jkqzy.png',
    },
    dianPuId:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that=this
    that.setData({
      dianPuId:options.dianPuId,
    })
  },

  //获取一个人的会员权益
  gethuiYuanQuanYi(){
    wx.showLoading({
      title: '获取中...',
      mask: true
    })
    var that=this
    var data={
      dianPuId:that.data.dianPuId,
    }
    request.get('person/huiYuanQuanYi', data, res => {
      wx.hideLoading()
      console.log("获取一个人的会员权益:"+JSON.stringify(res.data))
      const quanyiList = res.data.map(item => ({
        ...item,
        name: this.data.roleTexts[item.role].text,
        imageUrl: this.data.roleImages[item.role],
      }));
        that.setData({
          equitylist: quanyiList,
        })
    })
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.gethuiYuanQuanYi()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})